
package com.ikamobile.intentexp;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class ExpReceiver extends BroadcastReceiver {

    public static final String FILTER_ACTION_ONLY = "com.ikamobile.intentexp.FILTER_ACTION_ONLY";
    public static final String FILTER_ACTION_EMPTY_DATA = "com.ikamobile.intentexp.FILTER_ACTION_EMPTY_DATA";
    public static final String FILTER_ACTION_DATA_SCHEME = "com.ikamobile.intentexp.FILTER_ACTION_DATA_SCHEME";
    public static final String FILTER_ACTION_CATEGORY = "com.ikamobile.intentexp.FILTER_ACTION_CATEGORY";

    public static final String URI_SCHEME = "s";
    public static final String POST_RESULT = "com.ikamobile.intentexp.POST_RESULT";

    protected static final String EXTRA_RESULT = "EXTRA_RESULT";

    @Override
    public void onReceive(Context context, Intent intent) {
        Intent resultBroadcast = new Intent(POST_RESULT);
        String action = intent.getAction();
        action = action.substring(action.lastIndexOf("."), action.length());
        String result = String
                .format("Action=%s, data=%s, type=%s, flags=%d, categories=%s\n", action,
                        intent.getDataString(), intent.getType(), intent.getFlags(),
                        intent.getCategories());
        resultBroadcast.putExtra(EXTRA_RESULT, result);
        context.sendBroadcast(resultBroadcast);
    }

}
